using SqlSugar;

namespace MES_workbench.Domian.Entities
{
    /// <summary>
    /// 聊天会话实体
    /// </summary>
    [SugarTable("chat_sessions")]
    public class ChatSession
    {
        /// <summary>
        /// 会话ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, Length = 50)]
        public string SessionId { get; set; } = string.Empty;

        /// <summary>
        /// 用户ID
        /// </summary>
        [SugarColumn(Length = 50)]
        public string? UserId { get; set; }

        /// <summary>
        /// 会话标题
        /// </summary>
        [SugarColumn(Length = 200)]
        public string Title { get; set; } = "新对话";

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime UpdatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否活跃
        /// </summary>
        public bool IsActive { get; set; } = true;
    }

    /// <summary>
    /// 聊天消息实体
    /// </summary>
    [SugarTable("chat_messages")]
    public class ChatMessage
    {
        /// <summary>
        /// 消息ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, Length = 50)]
        public string MessageId { get; set; } = string.Empty;

        /// <summary>
        /// 会话ID
        /// </summary>
        [SugarColumn(Length = 50)]
        public string SessionId { get; set; } = string.Empty;

        /// <summary>
        /// 消息类型：user/assistant
        /// </summary>
        [SugarColumn(Length = 20)]
        public string MessageType { get; set; } = string.Empty;

        /// <summary>
        /// 消息内容
        /// </summary>
        [SugarColumn(ColumnDataType = "TEXT")]
        public string Content { get; set; } = string.Empty;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 响应时间（毫秒）
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? ResponseTimeMs { get; set; }
    }
}
